package cn.edu.sjtu.stap.cfg.internal;

import org.aspectj.org.eclipse.jdt.internal.compiler.ast.*;

import cn.edu.sjtu.stap.hg.builder.*;
import cn.edu.sjtu.stap.util.*;

public aspect HgBuilderAdapter {
    declare precedence : HgBuilderAdapter, CgBuilderAdapter;

    before(CompilationUnitDeclaration u, int index) : AstFetcher.astFetcherPc(u, index) {
        try {
            IHgBuilder builder = Initializer.getHgBuilder();

            builder.buildHierarchyGraph(u);

            AstArray.getInstance().addCompilationUnitDeclaration(u);
        } catch (Throwable e) {
            System.err.println("Caught unexpected exception in Hierarchy Graph construction!");
            e.printStackTrace();
        }
    }
}
